package cn.outsourcing.supermarket.controller.backstage;

import cn.outsourcing.supermarket.common.Result;
import cn.outsourcing.supermarket.common.utils.ResultUtils;
import cn.outsourcing.supermarket.dto.OnlyIdPayloadDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageAdminInfoDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageShowSettingsDTO;
import cn.outsourcing.supermarket.service.HiolabsAdminService;
import cn.outsourcing.supermarket.service.HiolabsShowSettingsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 管理员控制器
 *
 * @author gzkemays
 * @since 2021/11/5 2:29
 */
@RestController
@RequestMapping("/admin/admin")
public class AdminController {
  @Resource HiolabsShowSettingsService showSettingsService;
  @Resource HiolabsAdminService adminService;

  @GetMapping("/showset")
  public Result showSettings() {
    return ResultUtils.simpleResult(showSettingsService.showSettings());
  }

  @PostMapping("/showsetStore")
  public Result showSetStore(@RequestBody BackstageShowSettingsDTO dto) {
    return ResultUtils.simpleResult(showSettingsService.showSetStore(dto));
  }

  @PostMapping("/adminDetail")
  public Result adminDetail(@RequestBody OnlyIdPayloadDTO dto) {
    return ResultUtils.simpleResult(adminService.getAdminInfo(dto));
  }

  @PostMapping("/adminSave")
  public Result adminSave(@RequestBody BackstageAdminInfoDTO dto) {
    return ResultUtils.simpleResult(adminService.adminSave(dto));
  }
}
